using System;
using System.Collections.Generic;
using System.Text;

namespace ca.metaobjects.csogateway
{
	/// <summary>
	/// Message for exceptions thrown by the CSO Gateway.
	/// </summary>
	internal class ExceptionMessage
	{
		internal string id;
		internal string message;
		private ExceptionMessage(string i, string m) { id = i; message = m; }

		#region Importer exceptions

		internal static readonly ExceptionMessage I_000 = new ExceptionMessage("EXC-I-000",
			"Request made to this HTTP handler must have exactly one key/value pair in the query string.");

		internal static readonly ExceptionMessage I_001 = new ExceptionMessage("EXC-I-001",
			"No command or command unknown. Valid commands are {0}.");

		internal static readonly ExceptionMessage I_002 = new ExceptionMessage("EXC-I-002",
			"Circular reference detected among scripts to be imported.");

		#endregion

		#region Loader exceptions

		internal static readonly ExceptionMessage L_000 = new ExceptionMessage("EXC-L-000",
			"Type: {0}. Cso-generated types can be created only for classes, structs and enums.");

		internal static readonly ExceptionMessage L_001 = new ExceptionMessage("EXC-L-001",
			"Generic types cannot be made cso-ready.");

		internal static readonly ExceptionMessage L_002 = new ExceptionMessage("EXC-L-002",
			"Nested types cannot be made cso-ready.");

		internal static readonly ExceptionMessage L_003 = new ExceptionMessage("EXC-L-003",
			"Type: {0}. CsoGeneratedTypes can not be created for generic classes or structs.");

		#endregion

		#region Object Gateway

		internal static readonly ExceptionMessage OG_000 = new ExceptionMessage("EXC-OG-000",
			"The System.Int64 value {0} cannot be precisely representation by a javascript Number value.");

		internal static readonly ExceptionMessage OG_001 = new ExceptionMessage("EXC-OG-001",
			"The System.UInt64 value {0} cannot be precisely representation by a javascript Number value.");

		internal static readonly ExceptionMessage OG_002 = new ExceptionMessage("EXC-OG-002",
			"The System.Decimal value {0} cannot be precisely representation by a javascript Number value.");

		internal static readonly ExceptionMessage OG_003 = new ExceptionMessage("EXC-OG-003",
			"Attempt to pass object ({0}) in the CsoGateway failed. The type of this object ({1}) is not cso-compatible.");

		#endregion

		#region Type Morpher exceptions

		internal static readonly ExceptionMessage TM_002 = new ExceptionMessage("EXC-TM-002",
			"Class: {0}, Property: {1}, Return type: {2}. The return type is not cso-compatible.");

		#endregion

	}

	/// <summary>
	/// Message for warnings sent by the CSO Gateway.
	/// </summary>
	internal class WarningMessage
	{
		internal string id;
		internal string message;
		private WarningMessage(string i, string m) { id = i; message = m; }

	}

	/// <summary>
	/// Message for error exception thrown by the CSO Gateway.
	/// </summary>
	internal class ErrorMessage
	{
		internal string id;
		internal string message;
		private ErrorMessage(string i, string m) { id = i; message = m; }

		#region Importer errors

		internal static readonly ErrorMessage I_000 = new ErrorMessage("ERR-I-000",
			"ScriptDependency created before the corresponding 2 ScriptDescriptors object");

		#endregion

		#region Loader errors

		internal static readonly ErrorMessage L_000 = new ErrorMessage("ERR-L-000",
			"Error in creating CsoNativeType object for type {0}. The CsoNativeType object {0}.{1} should have been created already since it is a dependency.");

		internal static readonly ErrorMessage L_001 = new ErrorMessage("ERR-L-001",
			"Type: {0}. This type is already loaded. The corresponding Cso Generated type is {1}");

		internal static readonly ErrorMessage L_002 = new ErrorMessage("ERR-L-002",
			"Type: {0}. The class is not decorated with the CsoGeneratedTypeAttribute.");

		internal static readonly ErrorMessage L_003 = new ErrorMessage("ERR-L-003",
			"Type: {0}. The struct is not decorated with the CsoGeneratedTypeAttribute.");

		internal static readonly ErrorMessage L_004 = new ErrorMessage("ERR-L-004",
			"Type: {0}. Cannot create CsoGeneratedType for this type.");

		internal static readonly ErrorMessage L_005 = new ErrorMessage("ERR-L-005",
			"Manifest of CsoGateway assembly does not contain a resource with a name ending with {0}");

		#endregion

		#region Type Morpher errors

		internal static readonly ErrorMessage TM_000 = new ErrorMessage("ERR-TM-000",
			"Type: {0}. Only CsoTypes corresponding to classes and structs have base types.");

		#endregion

		#region Native Type Library errors

		internal static readonly ErrorMessage NTL_000 = new ErrorMessage("ERR-NTL-000",
			"The XML file containing the definition of the Native Type Library could not be deserialized.");

		#endregion

	}
}
